﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ewal.Msg;

namespace nbb.darbo_grafikas
{
    internal partial class FormSelectDates : Form
    {
        internal FormSelectDates()
        {
            InitializeComponent();            
        }

        private void btnNext_Click(object sender, EventArgs e)
        {
            if ((dtpTo.Value - dtpFrom.Value).Days < 1)
            {
                Msg.InformationMsg(Messages.Default.Date2MustBeLater);
                return;
            }
            if ((dtpTo.Value - dtpFrom.Value).Days > 366)
            {
                Msg.InformationMsg(Messages.Default.DiffenceBetweenDatesTooBig);
                return;
            }
            Program.FromDate = dtpFrom.Value;
            Program.ToDate = dtpTo.Value;
            if (Program.ToDate.TimeOfDay < Program.FromDate.TimeOfDay)
            {
                Program.FromDate = Program.FromDate.Subtract(Program.FromDate.TimeOfDay - Program.ToDate.TimeOfDay);
                Msg.InformationMsg("");
            }
            //this.Visible = false;
            using (FormSchedule fs = new FormSchedule())
            {
                fs.ShowDialog();
            }
        }
    }
}
